package ai.people.platform.archives.ws.config;

import org.springframework.stereotype.Component;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import java.util.List;

/**
 * 网络套接字配置
 *
 * @author yuanqinglong
 * @date 2022/7/11 14:43
 */
@Component
public class WebSocketConfig extends ServerEndpointConfig.Configurator {

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        List<String> secs = request.getHeaders().get("Sec-WebSocket-Protocol");
        response.getHeaders().put("Sec-WebSocket-Protocol", secs);
        super.modifyHandshake(sec, request, response);
    }
}
